<?php
/*
 * Created on Mar 1, 2010
 * @author Vuong Minh Chau <mchau2083@yahoo.com>
 */
require_once APPPATH . "controllers/cmsbase.php";
class cms_career extends CmsBase {
	var $_require_login = true;

	function __construct() {
		parent :: __construct();
		// Check permission
		parent::_check_permission('pms_career');
		$this->load->model('Model_career', 'model_career');
		$this->load->helper('date');
	}

	function index(){
		// Load pagination

		return $this->_render_my_view(array());
	}

	function add(){
		if(!empty($_POST['Submit'])){
			$data = parse_input('item_', $_POST);
			$this->model_career->insert_career($data);

			redirect(site_url(array('c' => 'cms_career', 'm' => 'index')), "refresh");
		}else{
			return $this->_render_my_view(array ());
		}
	}

	function edit($id){
		if(intval($id)>0){
			if(!empty($_POST['Submit'])){
				$data = parse_input('item_', $_POST);
				$data['is_important'] =  isset($_POST['item_is_important'])?1:0;
				$this->model_career->update_career($data,$id);

				redirect(site_url(array('c' => 'cms_career', 'm' => 'index')), "refresh");
			}else{
				return $this->_render_my_view(array ());
			}
		}
		return false;
	}

	function delete($id){
		$this->model_career->delete_career($id);
		redirect(site_url(array('c' => 'cms_career', 'm' => 'index')), "refresh");
	}
}
?>
